﻿using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Loyalty.Core.Entities
{
    public class ProfileJob
    {
        public virtual int Id { get; set; }

        public virtual string CorporateTitle { get; set; }

        public virtual JobType JobType { get; set; }

        public virtual int? LinkJobTypeId { get; set; }

        public virtual DateTime FromYear { get; set; }

        public virtual DateTime ToYear { get; set; }

        public virtual bool IsWorking { get; set; }

        public virtual Profile Profile { get; set; }

        public virtual int? LinkProfileId { get; set; }


    }
}

namespace Loyalty.Core.Entities.Mapping
{
    public class ProfileJobMap : EntityTypeConfiguration<ProfileJob>
    {
        public ProfileJobMap()
        {
            this.ToTable("ProfileJob");
            this.HasKey(x => x.Id);

            this.Property(x => x.CorporateTitle).HasMaxLength(300).HasColumnName("CorporateTitle");
            this.Property(x => x.FromYear).HasColumnName("FromYear");
            this.Property(x => x.ToYear).HasColumnName("ToYear");
            this.Property(x => x.IsWorking).HasColumnName("IsWorking");

            this.HasOptional(x => x.JobType).WithMany(x => x.ProfileJobs).HasForeignKey(x => x.LinkJobTypeId);
            this.HasOptional(x => x.Profile).WithMany(x => x.ProfileJobs).HasForeignKey(x => x.LinkProfileId);
        }
    }
}